package com.naiterui.ehp.bs.cms.modules.statistics.controller.inner;

import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.bo.agent.ProvinceItemBO;
import com.naiterui.ehp.bp.bo.statistics.CustomOrderReportBO;
import com.naiterui.ehp.bp.bo.statistics.CustomProductReportBO;
import com.naiterui.ehp.bp.bo.statistics.CustomRecipelConsultReportBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportInviteBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportProductBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportRecipelBO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.security.annotation.AnonymousGetMapping;
import com.naiterui.ehp.bs.cms.common.vo.PageParamsVO;
import com.naiterui.ehp.bs.cms.modules.statistics.service.IStatisticsService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 经纪人数据统计
 *
 * @author yangfuya
 * @since 2022/1/5
 */
@Slf4j
@Validated
@Api(tags = {SwaggerTag.CMS + SwaggerTag.INNER_API + SwaggerTag.AGENT_MANGEN})
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/statistics")
public class InnerStatisticsController {
    private final IStatisticsService statisticsService;

    /**
     * 客户详情-数据报表处方相关
     */
    @AnonymousGetMapping("/getRecipelAndConsult")
    public CustomRecipelConsultReportBO getRecipelAndConsult(Long customId, Integer reportType, String reportDate) {
        log.info("查询客户详情-数据报表处方相关：customId{}, reportType: {}, reportDate: {}", customId, reportType, reportDate);
        return this.statisticsService.getRecipelAndConsult(customId, reportType, reportDate);
    }

    /**
     * 客户详情-数据报告药品
     */
    @AnonymousGetMapping("/getProduct")
    public CustomProductReportBO getProduct(Long customId, Integer reportType, String reportDate) {
        log.info("查询客户详情-数据报告药品：customId{}, reportType: {}, reportDate: {}", customId, reportType, reportDate);
        return statisticsService.getProduct(customId, reportType, reportDate);
    }

    /**
     * 客户详情-数据报告订单
     */
    @AnonymousGetMapping("/getOrder")
    public CustomOrderReportBO getOrder(Long customId, Integer reportType, String reportDate) {
        log.info("查询客户详情-数据报告订单：customId{}, reportType: {}, reportDate: {}", customId, reportType, reportDate);
        return statisticsService.getOrder(customId, reportType, reportDate);
    }

    /**
     * 数据报表-首页
     */
    @AnonymousGetMapping("/getDateReportIndex")
    public DataReportBO getDateReportIndex(Long agentId) {
        log.info("查询数据报告首页：agentId{}", agentId);
        return statisticsService.getDateReportIndex(agentId);
    }

    /**
     * 数据报表-处方相关
     */
    @AnonymousGetMapping("/getRecipelDateReport")
    public DataReportRecipelBO getRecipelDateReport(Long agentId, Integer reportType, String reportDate) {
        log.info("查询数据报表-处方相关：agentId{}, reportType: {}, reportDate: {}", agentId, reportType, reportDate);
        return statisticsService.getRecipelDateReport(agentId, reportType, reportDate);
    }

    /**
     * 数据报表-邀请医生
     */
    @AnonymousGetMapping("/getInviteDataReport")
    public DataReportInviteBO getInviteDataReport(Long agentId, Integer reportType, String reportDate) {
        log.info("查询数据报表-邀请医生：agentId{}, reportType: {}, reportDate: {}", agentId, reportType, reportDate);
        return statisticsService.getInviteDataReport(agentId, reportType, reportDate);
    }

    /**
     * 数据报告-商品售卖
     */
    @AnonymousGetMapping("/getProductPage")
    public PageVO<DataReportProductBO> getProductPage(int pageNo, int pageSize, Long agentId, Integer reportType,
        String reportDate) {
        log.info("查询数据报告-商品售卖：agentId{}, reportType: {}, reportDate: {}", agentId, reportType, reportDate);
        PageParamsVO paramsVO = new PageParamsVO();
        paramsVO.setPageNo(pageNo);
        paramsVO.setPageSize(pageSize);
        return statisticsService.getProduct(paramsVO, agentId, reportType, reportDate);
    }

    /**
     * 区域统计-省份统计
     */
    @AnonymousGetMapping("/getProviceTotal")
    public List<ProvinceItemBO> getProviceTotal(@RequestParam Long areaId, @RequestParam String proviceAreaIStr,
        String year, String month) {
        log.info("查询区域统计-省份统计：proviceAreaIStr{}, year: {}, month: {}", proviceAreaIStr, year, month);
        return statisticsService.getProviceTotal(areaId, proviceAreaIStr, year, month);
    }
}
